package com.itheima.web.controller;

import com.itheima.util.OssUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class FileController {

    @PostMapping("/file/upload")
    @ResponseBody
    public String upload(MultipartFile uploadFile) throws IOException {
        // 调用oss工具类完成文件上传
        String picUrl = OssUtil.upload(uploadFile.getOriginalFilename(), uploadFile.getInputStream());
        return picUrl;
    }
}
